// #ifdef APP-PLUS
var view;
let noCreateList = ['index', 'user']
function createView(){
	// await Vue.prototype.$nextTick()
	let route = Vue.prototype.$Route.name;
	if (!noCreateList.includes(route)) return
	
	let bottom = 0;
	let isNotchInScreen = plus.navigator.hasNotchInScreen();
	if (isNotchInScreen) {
		bottom = plus.navigator.getSafeAreaInsets().bottom;
	}
	const width = Vue.prototype.$windowWidth;
	view = new plus.nativeObj.View('tabbarStopView',{bottom:bottom+'px',left:'0px',height:'50px',width:'100%',backgroundColor:'rgba(0,0,0,0)'});
	let itemW = width/5;

	view.addEventListener('click',e=>{
		let name = ''
		switch(true){
			case e.clientX < itemW:
				name = 'index';
				break;
			case e.clientX < itemW*2:
				name = '';
				break;
			case e.clientX < itemW*3:
				name = '';
				break;
			case e.clientX < itemW*4:
				name = '';
				break;
			case e.clientX < itemW*5:
				name = 'mine';
				break;
		}
		name && openPage(name)
	})
}

function viewShow(){
	// console.debug('viewshow',view);
	if (view) {
		view.show();
	}else{
		createView()
		setTimeout(()=>{
			view && view.show();
		},30)
	}
}

function viewHide(){
	// console.debug('view',view);
	view && view.hide();
}

function viewClose(){
	view && view.close();
}

function openPage(name){
	console.debug('name', name);
	if(!name) return;
	if(Vue.prototype.$Route.name == name){
		// Vue.prototype.$u.debounce(()=>{
		// 	name != 'user' && Vue.prototype.$store.dispatch('tabs/set_pageReScroll', name)
		// 	setTimeout(()=>{
		// 		Vue.prototype.$store.dispatch('tabs/set_pageReScroll', '')
		// 	},300)
		// },300)
	}else{
		Vue.prototype.$Router.pushTab({
			name
		})
	}
}

export default {
	createView,
	viewShow,
	viewHide,
	viewClose,
}
// #endif
